package com.zu.commu.auto1_0.protocol.clock;

import com.zu.commu.auto1_0.*;
import com.zu.commu.auto1_0.protocol.*;
import com.zu.commu.exception.CommuException;
import com.zu.commu.interf.Data;

public class SetClockDataProtocol {
    public Data analyseReportData(byte[] b)
            throws Exception {
        new CheckData().checkCrc(b, 4, 11, 12);
        Data d = new Data();
        getMeterNo(b, d);
        d.setDataType(DataType1_0.SETCLOCK.toInt() + "");
        return d;
    }

    private void getMeterNo(byte[] b, Data d)
            throws Exception {
        try {
            Util u = new Util();
            d.setMeterNo(u.byte2Hex(b, 4, 9));
        } catch (Exception e) {
            throw new CommuException().setMessage("从上报数据中读取测控器地址号时出错！" +
                    e.getMessage(), null);
        }
    }
}
